package common

import "math"

func CalcPageStartEnd(page, size, totalCount int) (pageStart, pageEnd int) {
	pageStart = (page - 1) * size
	pageEnd = pageStart + size
	if pageStart > totalCount {
		pageStart = 0
		pageEnd = 0
		return
	}
	if pageEnd > totalCount {
		pageEnd = totalCount
	}
	return
}

func CalcPages(totalCount int64, size int) int {
	return int(math.Ceil(float64(totalCount) / float64(size)))
}
